'''
Created on May 7, 2011

@author: yc30v1m
'''
from library.AutoLoad import AutoLoad
from logging import getLogger

log = getLogger(__name__)

class Broadcast(object):
    '''
    classdocs
    '''


    def __init__(self):
        self._observers = []

    def attach(self, observer):
        if not observer in self._observers:
            self._observers.append(observer)

    def detach(self, observer):
        try:
            self._observers.remove(observer)
        except ValueError:
            pass

    def notify(self, modifier=None):
        for observer in self._observers:
            log.debug("Notify TestResult at Listner :" + str(observer))
            if modifier != observer:
                try:
                    observer.updateResult(self)
                except:
                    log.warning("Unable to update all Listening Test Reporters")
                    AutoLoad.logExceptionInfo()  
        